package com.example.one_class.Merchant.merchant;

import com.example.one_class.Merchant.pojo.Merchant;
import com.example.one_class.Merchant.pojo.MerchantType;
import com.example.one_class.Merchant.service.MerchantService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import sun.security.provider.MD5;

import javax.annotation.Resource;

@RestController
@RequestMapping("merchant")
public class MerchantHandler {

    @Resource
    private MerchantService merchantService;

    @RequestMapping("add")
    public R addMerchant(@RequestBody MerchantRequestParams merchant){
        Merchant merchant_obj = merchantService.findMerchantByName(merchant.getMname());
        if (merchant_obj !=null) {
            Return R.fail("您注册的用户已存在");
        }
        merchant.setMpassword(MD5.getMD5Hash(merchant.getMpassword()));
            return merchantService.addMerchant(merchant) > 0 ? R.ok(dala:"注册成功") ： R.fail("注册失败")
    }
}
